/*
 * @Title Swing.java
 * @Description ͼ��GUI
 * @Copyright Copyright(c) 2018
 * @Company com.lizhen
 * @author lizhen
 * @date 2018��10��22��
 * @version 0.0.1
 */
package com.lizhen.core.function.swing;

import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * @author lizhen
 */
public class Swing {

    private JFrame mainFrame;
    private JLabel headerLabel;
    private JLabel statusLabel;
    private JPanel controlPanel;

    /**
     * @author lizhen
     */
    public Swing() {
    }

    /**
     * @author lizhen
     */
    public static void main(String[] args) {
        new Swing().label();
    }

    private void label() {
        headerLabel = new JLabel("", JLabel.CENTER);
        headerLabel.setText("Control in action: JLabel");
        statusLabel = new JLabel("", JLabel.CENTER);
        statusLabel.setSize(350, 100);
        controlPanel = new JPanel();
        controlPanel.setLayout(new FlowLayout());
        JLabel label = new JLabel("", JLabel.CENTER);
        label.setText("Welcome to Swing Tutorial.");
        label.setOpaque(true);
        label.setBackground(Color.GRAY);
        label.setForeground(Color.WHITE);
        controlPanel.add(label);
        mainFrame = new JFrame("Swing");
        mainFrame.setSize(400, 400);
        mainFrame.setLayout(new GridLayout(3, 1));
        mainFrame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent windowEvent) {
                System.exit(0);
            }
        });
        mainFrame.add(headerLabel);
        mainFrame.add(controlPanel);
        mainFrame.add(statusLabel);
        mainFrame.setVisible(true);
    }

}
